﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Passion3DProject.src.Stuffs;
using Passion3DProject.src.About_the_Camera;
using Passion3DProject.src.Stuffs.About_Stages;
namespace Passion3DProject
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        #region Begin of Declaration
        GraphicsDeviceManager graphics;

        SpriteBatch spriteBatch;

        Stage1 stage1;

        public static float AspectRatio { get; set; }

        
        #endregion

        /// <summary>
        /// CONSTRUTOR PRINCIPAL
        /// </summary>
        #region Constructor
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = Engine.ScreenWidth;
            graphics.PreferredBackBufferHeight = Engine.ScreenHeight;
            Content.RootDirectory = "Content";
            IsMouseVisible = true;
        }
        #endregion

        /// <summary>
        /// INICIALIZAÇÃO PRINCIPAL
        /// </summary>
        #region Initialize 
        protected override void Initialize()
        {
            base.Initialize();
        }
        #endregion

        /// <summary>
        /// CARREGAMENTO Inicial
        /// </summary>
        #region LoadContent
        protected override void LoadContent()
        {
            AspectRatio = GraphicsDevice.DisplayMode.AspectRatio;
            spriteBatch = new SpriteBatch(GraphicsDevice);

            stage1 = new Stage1(Content,graphics);
        }
        #endregion

        /// <summary>
        /// GARBAGE COLLECTOR
        /// </summary>
        #region UnloadContent
        protected override void UnloadContent()
        {
        }
        #endregion

        /// <summary>
        /// UPDATE Principal
        /// </summary>
        /// <param name="gameTime"></param>
        #region Update
        protected override void Update(GameTime gameTime)
        {
            #region system's Stuff
            Engine.keyboard = Keyboard.GetState();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();
            Engine.currentMouseState = Mouse.GetState();
            #endregion
            // -> 
            stage1.Update(gameTime);
            // <-
            #region system's Stuff
            if (Engine.keyboard.IsKeyDown(Keys.F11))
            {
                graphics.ToggleFullScreen();
            }
            Engine.last_keyboard = Keyboard.GetState();
            #endregion
            base.Update(gameTime);
        }
        #endregion
        /// <summary>
        /// DRAW Principal
        /// </summary>
        /// <param name="gameTime"></param>
        #region Draw
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            stage1.Draw();
            base.Draw(gameTime);
        }
        #endregion
    }
}
